/*
 * Copyright (c) 2013-2018 上海汇数数据. All rights reserved.
 * @(#) BaseOutVO.java 2018-08-20 21:28
 */

package cn.jh.common.core.ret;

import com.google.common.base.MoreObjects;

import java.util.Objects;


/**
 * @author Fuchun
 * @since 1.0
 */
abstract class BaseOutVO implements OutVO {

    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        DefaultOutVO that = (DefaultOutVO) o;
        return Objects.equals(getCode(), that.getCode()) &&
                Objects.equals(getMessage(), that.getMessage()) &&
                Objects.equals(getDescription(), that.getDescription()) &&
                Objects.equals(getData(), that.getData());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getCode(), getMessage(), getDescription(), getData());
    }

    protected MoreObjects.ToStringHelper toStringHelper() {
        return MoreObjects.toStringHelper(getClass())
                .add("code", getCode())
                .add("message", getMessage())
                .add("description", getDescription())
                .add("data", getData());
    }

    @Override
    public String toString() {
        return toStringHelper().toString();
    }
}
